package com.kevin.mybatis.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kevin.mybatis.model.Article;
import com.kevin.mybatis.service.ArticleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Tag(name = "文章管理")
@RestController
@AllArgsConstructor
@RequestMapping("/article")
public class ArticleController {

    private final ArticleService articleService;

    @Operation(summary = "分页列表", description = "分页列表")
    @GetMapping("/page")
    public IPage<Article> page(@Parameter(name = "current", description = "页码", required = true)
                               @RequestParam(name = "current", defaultValue = "1") Long current,
                               @Parameter(name = "size", description = "数量", required = true)
                               @RequestParam(name = "size", defaultValue = "10") Long size) {
        return articleService.page(new Page<Article>().setCurrent(current).setSize(size));
    }

}
